/*Scott Wilkewitz & Matt Rodgers
 * swilkewi & rodgersm
 * Recitation:RM7 Lab Turnin:005
 * 
 * -------------------------------
 * Fully functional centipede game
 * Try to beat Chuck Norris
 */

import java.awt.*;
import javax.swing.*;

public class Project5
{
    
    private GameSounds myGameSounds;
    private HighScores myHighScores;
    public GameCanvas myGameCanvas;
    private GameLogic myGameLogic;
    private Frame myFrame;
    private Mushroom myMushrooms[][];
    private Centipede myCentipedes[];
    private Ship myShip;
    private Point myProjectiles[];
    
    /**
     * Starts the program
     * 
     * @param args Array of input strings.  Not used.
     **/
    public static void main(String[] args)
    {
        new Project5();
    }
    
    public Project5()
    {
      
      //Create new objects myGameSounds, myHighScores, myMushrooms,
      //myProjectiles, myShip, myCentipedes, myGameCanvas, myGameLogic, myFrame
      myGameSounds = new GameSounds();
      myHighScores = new HighScores();
      myMushrooms = new Mushroom[Settings.width][Settings.height];
      myProjectiles = new Point[10];
      myShip = new Ship(myGameSounds, myProjectiles);
      myCentipedes = new Centipede[20];
      myGameCanvas = new GameCanvas(myGameSounds, myMushrooms, myCentipedes, myShip, myProjectiles);
      myGameLogic = new GameLogic(myGameSounds, myGameCanvas, myHighScores, myMushrooms, myCentipedes, myShip, myProjectiles);
      myFrame = new Frame(myGameLogic, myGameCanvas, myHighScores);
      myGameLogic.myFrame = myFrame;
          
      //Set myGameCanvas.myGameLogic to myGameLogic
      myGameCanvas.myGameLogic = myGameLogic;
          
      //Set myHighScores.myFrame to myFrame
      myHighScores.myFrame = myFrame;
          
      //Set myGameLogic.syncReset to true
      myGameLogic.syncReset = true;
          
      //Start myGameLogic and then wait for it to join
      myGameLogic.start();
          
      try{
         myGameLogic.join();
      }catch(Exception e){}
   }
}